package services.user;

import dto.user.*;
import models.pubobj.AniObjectState;
import models.user.AniUser;
import models.user.AniUserRole;

public class AniLocalUserEditService extends AniLocalUserService {

	//-update user
	public static void updateUserInfo(LocalUserInfoDto userInfo){
		AniLocalUserService.checkUserUpdateInfo(userInfo);
		AniUser oneUser = userInfo.transToAniUserForUpdate();
		oneUser.update();
	}
	//-delete user(soft)
	public static void deleteUser(LocalUserInfoDto userInfo){
		AniUser oneUser = userInfo.getAniUserEntity();
		oneUser.state = AniObjectState.findByStateKey(AniObjectState.States.RETIRED.name());
		oneUser.update();
	}
	//-change user state
	public static void changeUserState(LocalUserInfoDto userInfo, AniObjectState oneState){
		AniUser oneUser = userInfo.getAniUserEntity();
		oneUser.state = oneState;
		oneUser.update();
	}
	//-change user role
	public static void changeUserRole(LocalUserInfoDto userInfo, AniUserRole targetRole){
		AniUser oneUser = userInfo.getAniUserEntity();
		oneUser.role = targetRole;
		oneUser.update();
	}
}
